﻿using UnityEngine;

namespace UFrame
{
    /// <summary>
    /// 模拟子弹飞
    /// </summary>
    public class OUBullet : MonoBehaviour
    {
        public float speed = 10f;
        public Vector3 direction;
        public bool isMovement = false;

        public float destroyTime = 8f;
        private float destroyCounter = 0f;

        public void Update()
        {
            if (isMovement)
                transform.position += direction * speed * Time.deltaTime;

            destroyCounter += Time.deltaTime;
            if (destroyCounter >= destroyTime)
            {
                DestroyImmediate(this.gameObject);
                return;
            }
        }
    }
}